{% extends 'base.html' %}
{% load static %}
<!-- 写入 base.html 中定义的 title -->
{% block title %}
成绩详情
{% endblock title %}

<!-- 写入 base.html 中定义的 content -->
{% block content %}

<div>
    <div class="container">
        <br>
        <div style="display: inline-block">
            <a class="btn btn-success" href="/addStudent" >
                <span class="glyphicon glyphicon-plus-sign"></span>添加学生
            </a>
        </div>


    <div class="panel panel-default">
        <div class="panel-heading">
            <span class="glyphicon glyphicon-th-list" aria-hidden="true"></span>
            成绩列表
        </div>

        <p></p>

        <table class="table ">
            <thead>
            <tr>
                <th>id</th>
                <th>学号</th>
                <th>姓名</th>
                <th>高数</th>
                <th>英语</th>
                <th>C语言</th>
                <th>JAVA</th>
                <th>Python</th>
                <th>数据结构</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {% for obj in gradeData %}
            <tr class="table">
                <td> {{ obj.id }}</td>
                <td>{{ obj.sno }}</td>
                <td>{{ obj.sname }}</td>
                <td>{{ obj.math }}</td>
                <td>{{ obj.english }}</td>
                <td>{{ obj.Clanguage }}</td>
                <td>{{ obj.JavaGrade }}</td>
                <td>{{ obj.PythonGrade }}</td>
                <td>{{ obj.DataStruct }}</td>
                <td>
                    <a class="btn btn-primary btn-xs" href="/gradeDetail/{{ obj.id }}/edit">编辑</a>
                    <a class="btn btn-danger btn-xs" href="/gradeDetail/{{ obj.id }}/delete">删除</a>

                </td>
            </tr>
            {% endfor %}

            </tbody>

        </table>
    </div>
    <button class="btn btn-warning" onclick="randomName()">随机生成一个学生</button>
    <button class="btn btn-warning" onclick="openSort()">排序</button>
    <a class="btn btn-warning" href="/download" id="getDownload">下载数据</a>
    <button class="btn btn-warning" onclick="dbsChart()">查看图表</button>
    <a class="btn btn-warning" href="/pandas">计算总分和均分</a>
    <a class="btn btn-warning" href="/download/calufile">下载计算后的文件</a>
    </div>


</div>

<script>
    function randomName() {
        ajax = new XMLHttpRequest()
        ajax.open('get', '/randomName/')
        ajax.send()
        ajax.onreadystatechange = function () {
            if (ajax.readyState === 4) {
                json = ajax.responseText
                obj = JSON.parse(json)
                alert(obj.name)
            }
        }
    }
    function openSort(){
        window.open('/sort')
    }

    function dbsChart(){
        window.open('/dbschart')
    }

</script>

{% endblock content %}